package com.alamiya.common.vo.result;

import com.alamiya.common.constant.ResponseCodeEnum;
import io.swagger.annotations.ApiModel;
import lombok.Data;

/**
 * @author HEHAOQI
 */
@ApiModel(value = "ResponseResult", description = "返回结果")
@Data
public class ResponseResult<T> {
    /**
     * 返回码
     */
    private Integer status;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 返回数据
     */
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(ResponseCodeEnum responseCodeEnum) {
        this.status = responseCodeEnum.getCode();
        this.message = responseCodeEnum.getDesc();
    }

    public ResponseResult(ResponseCodeEnum ResponseCodeEnum, T data) {
        this(ResponseCodeEnum);
        this.data = data;
    }

    public ResponseResult(Integer status, String message) {
        this.status = status;
        this.message = message;
    }

    public ResponseResult(Integer status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }



    public static ResponseResult success() {
        return new ResponseResult(ResponseCodeEnum.SUCCESS);
    }

    public static ResponseResult success(Object object) {
        return new ResponseResult(ResponseCodeEnum.SUCCESS, object);
    }

    public static ResponseResult success(Object object, String message) {
        return new ResponseResult(ResponseCodeEnum.SUCCESS.getCode(), message, object);
    }

    public static ResponseResult error() {
        return new ResponseResult(ResponseCodeEnum.FAILURE);
    }

    public static ResponseResult fail() {
        return new ResponseResult(ResponseCodeEnum.FAILURE);
    }

    public static ResponseResult fail(String msg) {
        return new ResponseResult(ResponseCodeEnum.FAILURE.getCode(), msg);
    }
    public static ResponseResult fail(ResponseCodeEnum ResponseCodeEnum) {
        return new ResponseResult(ResponseCodeEnum);
    }
    public static ResponseResult fail(ResponseCodeEnum ResponseCodeEnum, String msg) {
        return new ResponseResult(ResponseCodeEnum, msg);
    }
}
